package com.sydata.cdrdata.service.impl;


import com.sydata.cdrdata.domain.AgentFlowRecord;
import com.sydata.cdrdata.mapper.LinksFieldCdrMapper;
import com.sydata.cdrdata.mapper.LinksFieldCdrSettlementMapper;
import com.sydata.cdrdata.service.ILkCdrSettlementService;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;


/**
 * 领科话单流量池结算
 *
 * @author haungzj
 * @date 2024-05-30
 */
@Service
public class LkCdrSettlementServiceImpl implements ILkCdrSettlementService {

    @Autowired
    private LinksFieldCdrSettlementMapper linksFieldCdrSettlementMapper;

    /**
     * 查询领科话单汇总数据 按m渠道、mcc和和日期分组先汇总
     *
     * @return
     */
    public List<Map<String, Object>> getLkCdrRecordList() {
        return linksFieldCdrSettlementMapper.getLkCdrRecordList();
    }

    public Map<String, Object> getRatioByMccAndChannel(@Param("channelId") String channelId, @Param("simTypeId") String simTypeId, @Param("mcc") String mcc) {
        return linksFieldCdrSettlementMapper.getRatioByMccAndChannel(channelId, simTypeId, mcc);
    }

    /**
     * 更新渠道账户余额
     *
     * @param supplierId
     * @param channelId
     * @param money
     * @return
     */
    public int updateChannelBalance(@Param("supplierId") String supplierId, @Param("channelId") String channelId, @Param("money") double money) {
        return linksFieldCdrSettlementMapper.updateChannelBalance(supplierId, channelId, money);
    }

    /**
     * 新增结算记录
     * @param agentFlowRecord
     * @return
     */
    public int insertAgentFlowRecord(AgentFlowRecord agentFlowRecord){
        return linksFieldCdrSettlementMapper.insertAgentFlowRecord(agentFlowRecord);
    }
}
